<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>附件管理</title>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
				submitHandler: function (form) {
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorClass: 'validation-invalid-label',
				highlight: function(element, errorClass) {
						$(element).removeClass(errorClass);
				},
				errorPlacement: function (error, element) {
					validateErrorPlacement(error, element);
				}
			});
			layui.use('table', function(){
				layui.table.init('layui-filter-table1',{
					escape : false
					,height: getLayuiTableHeight() - ($('#input-form').outerHeight(true) || 0)
					,className: 'layui-table-custom'
					,done: function (res,curr,count){
					}
				});
			});
		});
	</script>

</head>
<body>
<div class="content">
	<sys:message content="${message}"/>
	<div class="card">
		<div class="card-body" id="input-form">
			<form:form id="inputForm" method="post"
					   modelAttribute="sysFile" enctype="multipart/form-data"
					   action="${ctxAdmin}/sys/sysFile/save2Upload" >
				<form:hidden path="id"/>
				<form:hidden path="hostId"/>
				<form:hidden path="hostIds"/>
				<form:hidden path="hostTable"/>

				<div class="form-group row">
					<label class="col-sm-3 col-form-label"><span class="text-danger">*</span>添加附件</label>
					<div class="col-sm-8">
						<input type="file" name="file" class="file-input required" data-show-preview="false" extension="docx,pdf">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label"><span class="text-danger">*</span>文件名称</label>
					<div class="col-sm-8">
						<form:input path="fileName" htmlEscape="false" maxlength="255" class="form-control required"/>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 col-form-label">文件描述</label>
					<div class="col-sm-8">
						<form:textarea path="fileDesc" htmlEscape="false" maxlength="255" class="form-control "/>
					</div>
				</div>
				<div class="text-center">
					<div class="btn-group">
						<shiro:hasPermission name="sys:sysFile:edit">
							<button id="btnSubmit" type="submit" type="submit" class="btn btn-primary rounded-round">
								<i class="icon-database-upload mr-2"></i>上 传</button>
						</shiro:hasPermission>
					</div>
				</div>
			</form:form>
		</div>
		<table id="layui-table-id1" lay-filter="layui-filter-table1" style="display: none;">
			<thead>
			<tr>
				<th lay-data="{type: 'numbers',align:'center',width:40}">#</th>
				<th lay-data="{field:'a.file_name'}">文件名称</th>
				<th lay-data="{field:'a.file_desc'}">文件描述</th>
				<th lay-data="{field:'a.file_ext',align:'center',width: 100}">类型</th>
				<th lay-data="{field:'a.file_size',align:'center',width: 100}">大小</th>
				<th lay-data="{field:'a.target_date',align:'center',width: 150}">有效日期</th>
				<th lay-data="{field:'a.update_date',align:'center',width: 150}">修改时间</th>
				<shiro:hasPermission name="sys:sysFile:edit">
					<th lay-data="{field:'opt',align:'center',width: 120,minWidth:120,fixed:'right'}">操作</th>
				</shiro:hasPermission>
			</tr>
			</thead>
			<tbody>
			<c:forEach items="${filesList}" var="sysFile">
				<tr>
					<td></td>
					<td>${sysFile.fileName}</td>
					<td>${sysFile.fileDesc}</td>
					<td>${sysFile.fileExt}</td>
					<td>${sysFile.fileSize}</td>
					<td><fmt:formatDate value="${sysFile.targetDate}" pattern="yyyy-MM-dd"/></td>
					<td><fmt:formatDate value="${sysFile.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<shiro:hasPermission name="sys:sysFile:edit">
						<td>
							<div class="btn-group">
								<button class="btn btn-danger"  data-url="${ctxAdmin}/sys/sysFile/delete?id=${sysFile.id}"
								   onclick="confirmOperation(this,'确认要删除该附件吗？')">删除</button>
							</div>
						</td>
					</shiro:hasPermission>
				</tr>
			</c:forEach>
			</tbody>
		</table>
	</div>
</div>
</body>
</html>